import { IPSSysDBScheme } from '../../database/ipssys-dbscheme';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from '../action/ipsdeaction';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { IPSDERawSqlAndLoopCallLogic } from './ipsderaw-sql-and-loop-call-logic';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';

export class PSDERawSqlAndLoopCallLogicImpl extends PSDELogicNodeImpl implements IPSDERawSqlAndLoopCallLogic {
  protected dstpsdeaction: IPSDEAction | null = null;

  getDstPSDEAction(): IPSDEAction | null {
    if (this.dstpsdeaction != null) return this.dstpsdeaction;
    const value = this.M.getDstPSDEAction;
    if (value == null) {
      return null;
    }
    this.dstpsdeaction = this.getPSModel4('dataentity.action.IPSDEAction', value, 'getDstPSDEAction') as IPSDEAction;
    return this.dstpsdeaction;
  }

  get dstPSDEAction(): IPSDEAction | null {
    return this.getDstPSDEAction();
  }

  getDstPSDEActionMust(): IPSDEAction {
    const value = this.getDstPSDEAction();
    if (value == null) {
      throw new Error('未指定目标实体行为对象');
    }
    return value;
  }

  protected dstpsdataentity: IPSDataEntity | null = null;

  getDstPSDataEntity(): IPSDataEntity | null {
    if (this.dstpsdataentity != null) return this.dstpsdataentity;
    const value = this.M.getDstPSDataEntity;
    if (value == null) {
      return null;
    }
    this.dstpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getDstPSDataEntity') as IPSDataEntity;
    return this.dstpsdataentity;
  }

  get dstPSDataEntity(): IPSDataEntity | null {
    return this.getDstPSDataEntity();
  }

  getDstPSDataEntityMust(): IPSDataEntity {
    const value = this.getDstPSDataEntity();
    if (value == null) {
      throw new Error('未指定目标实体对象');
    }
    return value;
  }

  protected pssysdbscheme: IPSSysDBScheme | null = null;

  getPSSysDBScheme(): IPSSysDBScheme | null {
    if (this.pssysdbscheme != null) return this.pssysdbscheme;
    const value = this.M.getPSSysDBScheme;
    if (value == null) {
      return null;
    }
    this.pssysdbscheme = this.getPSModel4('database.IPSSysDBScheme', value, 'getPSSysDBScheme') as IPSSysDBScheme;
    return this.pssysdbscheme;
  }

  get psSysDBScheme(): IPSSysDBScheme | null {
    return this.getPSSysDBScheme();
  }

  getPSSysDBSchemeMust(): IPSSysDBScheme {
    const value = this.getPSSysDBScheme();
    if (value == null) {
      throw new Error('未指定数据库体系');
    }
    return value;
  }

  get sql(): string {
    return this.M.sql;
  }

  protected srcpsdelogicparam: IPSDELogicParam | null = null;

  getSrcPSDELogicParam(): IPSDELogicParam | null {
    if (this.srcpsdelogicparam != null) return this.srcpsdelogicparam;
    const value = this.M.getSrcPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.srcpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.srcpsdelogicparam;
  }

  get srcPSDELogicParam(): IPSDELogicParam | null {
    return this.getSrcPSDELogicParam();
  }

  getSrcPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getSrcPSDELogicParam();
    if (value == null) {
      throw new Error('未指定附加源参数对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDERawSqlAndLoopCallLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDERawSqlAndLoopCallLogic') return true;
    return super.instanceof(cls);
  }
}
